import request from '@/utils/request'

// 文章 — 不感兴趣
export const dislikeArticleAPI = (articleId) => {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

// 文章 - 举报
export const reportArticleAPI = (articleId, type, remark) => {
  return request({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type,
      remark
    }
  })
}

// 获取文章详情
export const getArticleDetailAPI = (articleId) => {
  return request({
    method: 'get',
    url: `/v1_0/articles/${articleId}`
  })
}

// 关注
export const followAPI = (autId) => {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: autId
    }
  })
}

// 取关
export const unfollowAPI = (autId) => {
  return request({
    method: 'delete',
    url: `/v1_0/user/followings/${autId}`
  })
}

// 点赞
export const likeAPI = (articleId) => {
  return request({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

// 取赞
export const unlikeAPI = (articleId) => {
  return request({
    method: 'delete',
    url: `/v1_0/article/likings/${articleId}`
  })
}

// 获取评论列表
export const getCmtListAPI = (source, offset, limit) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source,
      offset,
      limit
    }
  })
}

// 文章评论点赞
export const likeCmtAPI = (cmtId) => {
  return request({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target: cmtId
    }
  })
}

// 文章评论取赞
export const unlikeCmtAPI = (cmtId) => {
  return request({
    method: 'delete',
    url: `/v1_0/comment/likings/${cmtId}`
  })
}

// 文章发表评论
export const publishCmtAPI = (artId, content) => {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: artId,
      content
    }
  })
}
